Page({
  data: {},
  onLoad() { },
  onTapGetAuthCode() {
    my.getAuthCode({
      scopes: "auth_user",
      success: (res) => {
        console.log("授权成功", res);
      },
      fail: (error) => {
        console.log("授权失败", error);
      }
    })
  },
  getOpenUserInfo(detail) {
    console.log('用户头像', detail);
  },
  getUserInfoApi() {
    my.getAuthCode({
      scopes: "auth_user",
      success: (res) => {
        console.log('getAuthCode 授权码', res.authCode);
        my.getAuthUserInfo({
          success: (userInfo) => {
            console.log('用户头像', userInfo);
          },
          fail: (error) => {
            console.log("获取用户头像失败", error);
          },
        })
      },
      fail: (error) => {
        console.log("getAuthCode 失败", error);
      }
    })
  },
  getPhoneNumber(detail) {
    console.log('授权手机号', detail);
  },
  getPhoneNumberApi() {
    my.getPhoneNumber({
      success: (res) => {
        console.log('获取手机号', res);
      },
      fail: (res) => {
        console.log(res);
      },
    });
  },
  handleAuthError(e) {
    console.log('失败', e);
  },
  onTapTradePay() {
    // .js
    my.tradePay({
      // 调用统一收单交易创建接口（alipay.trade.create），获得返回字段支付宝交易号trade_no
      tradeNO: '201711152100110410533667792',
      success: (res) => {
        my.alert({
          content: JSON.stringify(res),
        });
      },
      fail: (res) => {
        my.alert({
          content: JSON.stringify(res),
        });
      }
    });
  },
});
